﻿using System;

using CrystalDecisions.Enterprise;

namespace BO.Management
{
    public class BOScheduleInformation
    {

        public Int32 ID { get; private set; }
        public String Title { get; private set; }
        private InfoObject _instance;

        public BOScheduleInformation(Int32 instanceId, String instanceTitle, InfoObject instance)
        {
            _instance = instance;
            this.ID = instanceId;
            this.Title = instanceTitle;
        }


        public DateTime BeginDate
        {
            get
            {
                return (DateTime)_instance.Properties[BO.Management.QueryBuilder.InfoStoreFieldNames.CreationDate].Value;
            }
        }

        public DateTime? EndDate
        {
            get
            {
                if (_instance.SchedulingInfo.Status == CeScheduleStatus.ceStatusSuccess)
                    return _instance.SchedulingInfo.EndDate;
                else
                    return null;
            }
        }

        public CeScheduleStatus Status
        {
            get
            {
                return _instance.SchedulingInfo.Status;
            }
        }

        public CeScheduleOutcome OutCome
        {
            get
            {
                return _instance.SchedulingInfo.Outcome;
            }
        }

        public Int16 IntervalMonths
        {
            get
            {
                return _instance.SchedulingInfo.IntervalMonths;
            }
        }

        public String ErrorMessage
        {
            get
            {
                return _instance.SchedulingInfo.ErrorMessage;
            }
        }

    }
}
